/*
 *  EventManager.h
 *  Rempart
 *
 *
 */

#ifndef __EVENT_MANAGER
#define __EVENT_MANAGER
#include <SFML/Graphics.hpp>
#include "Constants.h"
#include <math.h>
#include "Map.h"


extern sf::Mutex globalLock;

class MouseOverPattern;

class EventManager : public sf::Thread {


private:


	bool loop;
	bool freeze;
	int currentStage;
	float totalTime;
	float boatFireTime;
	float elapsedTime;
	bool mapDumpLock;
	bool mapLoadLock;
	bool mouseLeftLock;
	bool mouseRightLock;
	bool mapNightLock;
	
	
	void processStageManagement();
	
	static EventManager* instance;
	MouseOverPattern* pattern;
	
	void processMouseManagement();
	sf::Clock* gameClock;
	sf::Vector2<float> mousePosition;
	sf::Vector2<int> mouseCasePosition;
	sf::Vector2<float> mouseMapRelativePosition;
	
		
	enum stage {
		noninit,
		wall,
		canons,
		attack,
	};
	
	EventManager();	//Cette classe est un singleton.

	virtual void Run();
	
public:

	void nextStage();
	static EventManager* getInstance();
	int getCurrentStage();
	const sf::Vector2<int>& getMouseCasePosition();
	const sf::Vector2<float>& getMousePosition();
	const sf::Vector2<float>& getMouseMapRelativePosition();
	~EventManager();
	void processEvents();
	float getElapsedTime();
	void stopLoop();
	void freezeLoop();
	void continueLoop();
	void startStage(int stage);
	void gameOver();
	
	
	
};

#endif